#include "NetworkManager.h"

namespace mp_net
{
		NetworkManager::NetworkManager(bool server)
		{
			if (server)
			{
				m_server = new TcpServer();
				m_client = NULL;
			}
			else
			{
				m_server = NULL;
				m_client = new TcpClient();
			}
		}

		NetworkManager::~NetworkManager()
		{
			delete m_server;
			delete m_client;
		}

		void NetworkManager::Initialize()
		{
			m_ioService.reset(new boost::asio::io_service());
			if (m_client != NULL)
			{
				m_client->SetIoService(m_ioService);
				m_client->StartThread();
			}
			else
			{
				m_server->SetIoService(m_ioService);
				m_server->StartThread();
			}
			m_initialized = true;
		}

		void NetworkManager::Uninitialize()
		{
			m_initialized = false;
		}

		void NetworkManager::Update()
		{
		
		}

		void NetworkManager::Run()
		{

		}
}